import api from '../index'

export interface AddCategoryPayload {
  agent_app_id: number
  category_id: number
  title: string
  province_code: string
  city_code: string
  county_code: string
  tag_ids: string
  status: string
  audit_status: number
  sorts: number
  other_fields: Array<{
    address?: string
    content?: string
  }>
}

export interface EditCategoryPayload {
  id: number
  name?: string
  title?: string
  enabled?: boolean
}

export default {
  index: () => api.post('agent/category/index'),
  detail: (id: number) => api.post('agent/category/detail', { id }),
  add: (data: AddCategoryPayload) => api.post('agent/category/add', data),
  delete: (id: number) => api.post('agent/category/delete', { id }),
  edit: (data: EditCategoryPayload) => api.post('agent/category/edit', data),
}
